package com.wc.alorithm_blue_bridge._前缀和与差分.异或和之和_位运算;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2025/3/5 17:42
 * @description
 * https://www.lanqiao.cn/courses/46292/learning/?id=3369766&compatibility=false
 */
public class Main {
    /**
     * 思路：
     * 只需要考虑 前缀和中 1 的贡献
     */
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 100010;
    static int[] a = new int[N], s = new int[N];
    static int[][] cnt = new int[20][2];
    static int n;

    public static void main(String[] args) {
        n = sc.nextInt();
        for (int i = 1; i <= n; i++) a[i] = sc.nextInt();
        for (int i = 1; i <= n; i++) s[i] = a[i] ^ s[i - 1];

        for (int i = 0; i < 20; i++) {
            for (int j = 0; j <= n; j++) {
                cnt[i][(s[j] >> i) & 1]++;
            }
        }
        long res = 0;
        for (int i = 0; i < 20; i++) {
            res += (long) cnt[i][0] * cnt[i][1] * (1 << i);
        }
        out.println(res);
        out.flush();
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}

